package com.yyd.designmodel.observer.impl;

import java.util.ArrayList;
import java.util.List;

import com.yyd.designmodel.observer.Watched;
import com.yyd.designmodel.observer.Watcher;

/**
 * 
 * @Description：[ 具体的主题，被观察者 ]
 *
 * @ProjectName：[designmodel]
 * @PackageName：[com.yyd.designmodel.observer.impl.ConcreteWatched]
 * @CreateDate：[2015-1-20  上午9:20:29] 
 * @Author：[yuyidi]
 */
public class ConcreteWatched implements Watched {
    //存放观察者
    private List<Watcher> list = new ArrayList<Watcher>();
    
    public void addWatcher(Watcher watcher) {
        list.add(watcher);
    }


    public void removeWatcher(Watcher watcher) {
        list.remove(watcher);
    }


    public void notifyWatcher(String string) {
        for (Watcher watcher : list) {
            watcher.update(string);
        }
    }

}
